package com.jason.rabbitmq.util;

import com.jason.rabbitmq.entity.Order;

import java.util.*;

public class OrderUtil {

    private static Map<String, Order> orderMap = new HashMap<>();

    public static void addOrder(Order order) {
        order.setId(UUID.randomUUID().toString());
        orderMap.put(order.getId(), order);
    }

    public static Order getOrder(String id) {
        return orderMap.get(id);
    }

    public static List<Order> getAllOrder() {
        List<Order> list = new ArrayList<>();
        orderMap.entrySet().forEach(entry -> {
            list.add(entry.getValue());
        });
        return list;
    }

}
